#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
    int n = 0;
    scanf("%d", &n);
    int arr1[n];
    int arr2[n + 1];
    int i = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &arr1[i]);
    }
    int k = 0;
    scanf("%d", &k);
    for (i = 0; i < n; i++)
    {
        if (arr1[i] < k)
        {
            arr2[i] = arr1[i];
        }
        else {

            break;
        }
    }
    arr2[i] = k;

    for (i; i < n; i++)
    {
        arr2[i + 1] = arr1[i];
    }
    for (i = 0; i <= n; i++)
    {
        printf("%d ", arr2[i]);
    }
    return 0;
}